﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ServiceNetworkDesign.Utilities;
using ServiceNetworkDesign.Impl;

namespace ServiceNetworkDesign
{
    public partial class TestForm : Form
    {
        public List<Node> nodeList = null;
        public TestForm()
        {
            InitializeComponent();
        }

        private void btnDijkstra_Click(object sender, EventArgs e)
        {
            DShortCutPath planner = new DShortCutPath();
            Path result = planner.GetPath(nodeList, "A", "D");

            planner = null;

        }

        private void btnKShort_Click(object sender, EventArgs e)
        {
            KShortCutPath planner = new KShortCutPath(1.6f);
            List<KPath> result = planner.GetKPath(nodeList, "A", "D");
            foreach(KPath kp in result)
            {
                MessageBox.Show(kp.EdgeList.ToString() + " weight=" + kp.TotalWeight+"\n");
            }
        }

        private void TestForm_Load(object sender, EventArgs e)
        {
            nodeList = new List<Node>();

            //***************** B Node *******************
            Node aNode = new Node("A");
            nodeList.Add(aNode);
            //A -> B
            Edge aEdge1 = new Edge();
            aEdge1.StartNodeID = aNode.ID;
            aEdge1.EndNodeID = "B";
            aEdge1.Weight = 10;
            aNode.EdgeList.Add(aEdge1);
            //A -> C
            Edge aEdge2 = new Edge();
            aEdge2.StartNodeID = aNode.ID;
            aEdge2.EndNodeID = "C";
            aEdge2.Weight = 20;
            aNode.EdgeList.Add(aEdge2);
            //A -> E
            Edge aEdge3 = new Edge();
            aEdge3.StartNodeID = aNode.ID;
            aEdge3.EndNodeID = "E";
            aEdge3.Weight = 30;
            aNode.EdgeList.Add(aEdge3);

            //***************** B Node *******************
            Node bNode = new Node("B");
            nodeList.Add(bNode);
            //B -> C
            Edge bEdge1 = new Edge();
            bEdge1.StartNodeID = bNode.ID;
            bEdge1.EndNodeID = "C";
            bEdge1.Weight = 5;
            bNode.EdgeList.Add(bEdge1);
            //B -> E
            Edge bEdge2 = new Edge();
            bEdge2.StartNodeID = bNode.ID;
            bEdge2.EndNodeID = "E";
            bEdge2.Weight = 10;
            bNode.EdgeList.Add(bEdge2);

            //***************** C Node *******************
            Node cNode = new Node("C");
            nodeList.Add(cNode);
            //C -> D
            Edge cEdge1 = new Edge();
            cEdge1.StartNodeID = cNode.ID;
            cEdge1.EndNodeID = "D";
            cEdge1.Weight = 30;
            cNode.EdgeList.Add(cEdge1);

            //***************** D Node *******************
            Node dNode = new Node("D");
            nodeList.Add(dNode);

            //***************** C Node *******************
            Node eNode = new Node("E");
            nodeList.Add(eNode);
            //E -> D
            Edge eEdge1 = new Edge();
            eEdge1.StartNodeID = eNode.ID;
            eEdge1.EndNodeID = "D";
            eEdge1.Weight = 20;
            eNode.EdgeList.Add(eEdge1);
        }
    }
}
